updating oE locate_file

locate_file

include filesys.e 
namespace filesys 
public function locate_file(sequence filename, sequence search_list = {}, 
        sequence subdir = {}) 

locates a file by looking in a set of directories for it.

Parameters:
  1. filename : a sequence, the name of the file to search for.
  2. search_list : a sequence, the list of directories to look in. By default this is "", meaning that a predefined set of directories is scanned. See comments below.
  3. subdir : a sequence, the sub directory within the search directories to check. This is optional.
Returns:

A sequence, the located file path if found, else the original file name.

Comments:

If filename is an absolute path, it is just returned and no searching takes place.

If filename is located, the full path of the file is returned.

If search_list is supplied, it can be either a sequence of directory names, of a string of directory names delimited by ':' in Unix and ';' in Windows.

If the search_list is omitted or "", this will look in the following places:

  • The current directory
  • The directory that the program is run from.
  • The directory in $HOME ($HOMEDRIVE & $HOMEPATH in Windows)
  • The parent directory of the current directory
  • The directories returned by include_paths
  • $EUDIR/bin
  • $EUDIR/docs
  • $EUDIST/
  • $EUDIST/etc
  • $EUDIST/data
  • The directories listed in $USERPATH
  • The directories listed in $PATH

If the subdir is supplied, the function looks in this sub directory for each of the directories in the search list.

Example 1:
 res = locate_file("abc.def", {"/usr/bin", "/u2/someapp", "/etc"}) 
 res = locate_file("abc.def", "/usr/bin:/u2/someapp:/etc") 
 res = locate_file("abc.def")  
       -- Scan default locations. 
 res = locate_file("abc.def", , "app")  
       -- Scan the 'app' sub directory in the default locations. 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu